package com.tfswx.jcyw.dmzc.component;

import com.intellij.ui.PopupMenuListenerAdapter;

import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import java.awt.*;

/**
 * @author ricky
 * @date 2023/2/7
 */
public abstract class AbstractFilterPopup extends JPopupMenu {

    public AbstractFilterPopup() {
        addPopupMenuListener(new PopupMenuListenerAdapter() {
            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                onClose();
            }

            @Override
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                initComponent();
            }
        });
    }

    public abstract Component initCenterComponent();

    public void initComponent() {
        this.add(initCenterComponent(), "Center");
    }

    public void onClose() {

    }
}
